Skip to content

Comments

chore: improve delegation error messages and reuse chainslot across retries#994

Merged
thlorenz merged 7 commits intomasterfrom
thlorenz/unresolved-deleg-improved-insight
Feb 24, 2026
Merged

chore: improve delegation error messages and reuse chainslot across retries#994
thlorenz merged 7 commits intomasterfrom
thlorenz/unresolved-deleg-improved-insight

Conversation

@thlorenz
Copy link
Collaborator

@thlorenz thlorenz commented Feb 23, 2026

Summary

Improve error messages for unresolved delegations and fetch failures by providing better insight into what caused the timeout or retry limit to be hit.

CLOSES: #988

Details

Reusing ChainSlot

  • originally we were using an up to date min context slot for each retry
  • now we capture it at the first try and reuse across retries to allow RPC to catch up

Error Message Improvements

Enhanced error diagnostics in the remote account provider to distinguish between two timeout failure modes:

  1. Max Retries Exceeded: Now explicitly states "max retries N" in the error
  2. Total Time Exceeded: Now explicitly states "max total time of X seconds" in the error

This allows operators to quickly understand which limit was hit and adjust configuration accordingly.

fetch_cloner

Changed error logging format from Display (%) to Debug (?) for better error introspection when delegation record fetch fails.

remote_account_provider

Updated error variants to include the specific limit that was hit:

  • SlotsDidNotMatch: Added limit string parameter
  • MatchingSlotsNotSatisfyingMinContextSlot: Added limit string parameter

The timeout/retry logic now checks both conditions simultaneously and includes the appropriate limit description in error messages.

Summary by CodeRabbit

  • Bug Fixes & Improvements
    • Retries now respect both max-attempt and total-time limits and maintain consistent fetch context across attempts.
    • Error messages now include explicit "hit limit" details (e.g., max retries or max total time) for clearer diagnostics.
    • Logging adjusted to surface richer debug information for certain error scenarios.

@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Manual Deploy Available

You can trigger a manual deploy of this PR branch to testnet:

Deploy to Testnet 🚀

Alternative: Comment /deploy on this PR to trigger deployment directly.

⚠️ Note: Manual deploy requires authorization. Only authorized users can trigger deployments.

Comment updated automatically when the PR is synchronized.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2128c1f and 3533fc9.

📒 Files selected for processing (1)
  • test-integration/test-chainlink/tests/ix_remote_account_provider.rs

📝 Walkthrough

Walkthrough

This PR changes two log formatting sites in fetch_cloner from Display to Debug, extends two RemoteAccountProviderError variants to include a limit String, threads an optional fetch_start_slot: Option through try_get_multi (updating its signature and call sites), records retry termination reasons ("max retries N" or "max total time of X seconds") and attaches them to errors, and updates tests to match the new error payloads and signature.

Assessment against linked issues

Objective (issue#) Addressed Explanation
Investigate why delegation-record fetch/parse failures occur and whether log level should be downgraded (#988) No investigation added and no changes to log levels; only formatting and extra error context were changed.
Include more contextual details about retry/termination in errors to aid diagnosis (#988)

Out-of-scope changes

Code Change Explanation
Changed try_get_multi signature to add fetch_start_slot: Option<u64> (magicblock-chainlink/src/remote_account_provider/mod.rs) Signature/API change not requested by the linked issue which focuses on logging and investigation; this is an interface change beyond diagnostic/logging scope.
Updated integration test call sites to pass new try_get_multi argument (test-integration/test-chainlink/tests/ix_remote_account_provider.rs) Test adjustments follow the signature change; test modifications are consequential but not part of the issue's stated objectives.

Suggested reviewers

  • GabrielePicco
✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch thlorenz/unresolved-deleg-improved-insight

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@magicblock-chainlink/src/remote_account_provider/errors.rs`:
- Around line 65-69: The error strings for SlotsDidNotMatch and
MatchingSlotsNotSatisfyingMinContextSlot need a separator before the appended
"hit limit:" clause; update the #[error(...)] messages for the enum variants
SlotsDidNotMatch and MatchingSlotsNotSatisfyingMinContextSlot to insert a comma
(or other suitable punctuation) just before "hit limit:" so the rendered
messages read naturally (e.g., "... to track slots, hit limit: ..." and "... min
required context slot 43, hit limit: ...").

@thlorenz thlorenz marked this pull request as ready for review February 23, 2026 07:30
Copy link
Collaborator

@GabrielePicco GabrielePicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
magicblock-chainlink/src/remote_account_provider/mod.rs (1)

646-681: 🧹 Nitpick | 🔵 Trivial

Consider using >= instead of == for the retry-limit check.

Using == works today because retries increments by exactly 1 each iteration, but >= is a more defensive guard against future refactors that might alter the increment pattern.

Suggested change
-            let hit_max_retry_limit = retries == config.max_retries;
+            let hit_max_retry_limit = retries >= config.max_retries;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@magicblock-chainlink/src/remote_account_provider/mod.rs` around lines 646 -
681, The retry-limit check should be defensive: change how hit_max_retry_limit
is computed so it uses >= rather than ==; specifically update the binding for
hit_max_retry_limit (currently let hit_max_retry_limit = retries ==
config.max_retries) to use retries >= config.max_retries so the branch handling
(the if hit_max_retry_limit || start.elapsed() > MAX_TOTAL_TIME { ... } block
and subsequent error construction in
RemoteAccountProviderError::SlotsDidNotMatch and
RemoteAccountProviderError::MatchingSlotsNotSatisfyingMinContextSlot) still
executes when retries has surpassed config.max_retries due to any future
increment changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@magicblock-chainlink/src/remote_account_provider/mod.rs`:
- Around line 646-681: The retry-limit check should be defensive: change how
hit_max_retry_limit is computed so it uses >= rather than ==; specifically
update the binding for hit_max_retry_limit (currently let hit_max_retry_limit =
retries == config.max_retries) to use retries >= config.max_retries so the
branch handling (the if hit_max_retry_limit || start.elapsed() > MAX_TOTAL_TIME
{ ... } block and subsequent error construction in
RemoteAccountProviderError::SlotsDidNotMatch and
RemoteAccountProviderError::MatchingSlotsNotSatisfyingMinContextSlot) still
executes when retries has surpassed config.max_retries due to any future
increment changes.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82e46b0 and 2128c1f.

📒 Files selected for processing (2)
  • magicblock-chainlink/src/chainlink/fetch_cloner/mod.rs
  • magicblock-chainlink/src/remote_account_provider/mod.rs

@thlorenz thlorenz changed the title chore: improve delegation error messages chore: improve delegation error messages and reuse chainslot across retries Feb 24, 2026
@thlorenz thlorenz merged commit 77f5cee into master Feb 24, 2026
18 checks passed
@thlorenz thlorenz deleted the thlorenz/unresolved-deleg-improved-insight branch February 24, 2026 05:57
thlorenz added a commit that referenced this pull request Feb 24, 2026
* master:
  chore: improve delegation error messages and reuse chainslot across retries (#994)
  release: 0.8.1 (#998)
  Create RELEASE_PROCESS.md (#997)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: fetching delegation record for not delegated account

2 participants